package fragments;

import java.util.ArrayList;

import org.tacademy.basic.calendar.CalendarAdapter;
import org.tacademy.basic.calendar.CalendarData;
import org.tacademy.basic.calendar.CalendarManager;
import org.tacademy.basic.calendar.CalendarManager.NoComparableObjectException;
import org.tacademy.basic.calendar.ItemData;
import org.tacademy.basic.calendar.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

public class CalListFragment extends Fragment {
	
	ListView listView;
	CalendarAdapter mAdapter;

	ArrayList<ItemData> mItemdata = new ArrayList<ItemData>();
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View v = inflater.inflate(R.layout.cal_list_fragment, container, false);
//		 mItemdata.add(new ItemData(2012,4,10,"A"));
//		    mItemdata.add(new ItemData(2012,4,11,"B"));
//		    mItemdata.add(new ItemData(2012,4,12,"C"));
//		    mItemdata.add(new ItemData(2012,4,15,"D"));
//		    mItemdata.add(new ItemData(2012,4,21,"E"));
//		    mItemdata.add(new ItemData(2012,4,21,"F"));
//	      
		
		    try {
				CalendarManager.getInstance().setDataObject(mItemdata);
			} catch (NoComparableObjectException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		    CalendarData data = CalendarManager.getInstance().getCalendarData();
		listView = (ListView)v.findViewById(R.id.list);
		mAdapter = new CalendarAdapter(getActivity(),data);
		listView.setAdapter(mAdapter);
		mAdapter.notifyDataSetChanged();
		
		return v;
	}
}
